<template>
	<view>
		<u-sticky>
			<u-tabs :list="list" active-color="#FA9700" :is-scroll="false" :current="current" @change="change"></u-tabs>
		</u-sticky>
		
		<view-NoData v-if="yuList.length==0">
			
		</view-NoData>
		<view>
			<u-cell-group>
				<u-cell-item v-for="(items,index) in yuList" :key="index" :title="items.memo" label="" :arrow="false">
					<view style="color: #FD8521;" slot="right-icon">
						{{items.type}}{{items.money}}
					</view>
				</u-cell-item>

			</u-cell-group>
		</view>
		
	</view>
</template>

<script>
	import {
		yuprice
	} from "@/common/config/request.js"
	export default {
		data() {
			return {
				list: [{
					name: '全部'
				}, {
					name: '支出明细'
				}, {
					name: '增加明细',
				}],
				current: 0,
				pageNum:1,//页数
				totalPage:0,//总页数
				yuList:[],//数据
			}
		},
		onLoad() {
			this.getYU()
		},
		methods: {
			change(index) {
				this.current = index;
				// console.log(this.current)
				this.pageNum=1
				this.yuList=[]
				this.getYU()
			},
			getYU(){
				let data={
					type:this.current==0?'':this.current,
					pages:this.pageNum
				}
				yuprice(data).then(res=>{
					// console.log(res)
					if(res.data.code==1){
						this.totalPage=res.data.data.last_page
						this.yuList=[...this.yuList,...res.data.data.data]
					}
				})
			}
		},
		onReachBottom() {
			if(this.pageNum<this.totalPage){
				this.pageNum++
				this.getYU()
			}else{
				uni.showToast({
					icon:'none',
					title:'暂无更多数据'
				})
			}
		}
	}
</script>

<style>

</style>
